//
//  FSLNormalAlertView.m
//  比柚UI测试项目
//
//  Created by 我演示 on 2019/10/21.
//  Copyright © 2019 Jerry-Fu. All rights reserved.
//

#import "FSLNormalAlertView.h"
#import "Masonry.h"

@interface FSLNormalAlertView ()
// 目前看，具有四个控件的位置，


/**1: 背景图层*/
@property(nonatomic,weak) UIView *backView ;

/**2: 提示框View*/
@property(nonatomic,weak) UIView    *whiteView  ;

/**3:上层提示titile*/
@property(nonatomic,weak) UILabel *titleLabel ;

/**4：提示线内容*/
@property(nonatomic,weak) UIView *landsFirstViewLine ;


/**5:左侧按钮信息*/
@property(nonatomic,weak) UIButton *leftBtn ;

/**6:中间的提示线条*/
@property(nonatomic,weak) UIView *vertialSecondViewLine ;

/**7:右侧的按钮实现*/
@property(nonatomic,weak) UIButton *rightBtn ;





@end

@implementation FSLNormalAlertView

-(instancetype)initWithTitle:(NSString *)titleString andLeftString:(NSString  *)leftString rightString:(NSString *)rightString{
    
    /// 添加各种对应的内容信息
    if (self =  [super init]) {
        
        self.backgroundColor = [UIColor clearColor];
        /**1:backView*/
        UIView *backView = [[UIView alloc] init];
        backView.backgroundColor = [UIColor colorWithHexString:@"#000000"] ;
        backView.alpha = 0.5;
        [self addSubview:backView];
        self.backView = backView;
        
        /**白色框view*/
        UIView *whiteView = [[UIView alloc] init];
        whiteView.backgroundColor = [UIColor whiteColor];
        whiteView.layer.masksToBounds = YES ;
        whiteView.layer.cornerRadius = 7.0;
        [self addSubview:whiteView];
        self.whiteView = whiteView;
        
        /**2:titleLabel*/
        UILabel *titleLabel = [[UILabel alloc]initWithTextString:titleString andTextColor:[UIColor colorWithHexString:@"#333333"] andTextFont:16];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        [whiteView addSubview:titleLabel];
        self.titleLabel = titleLabel ;
        
        /**3:横向的LineView分割线*/
        UIView *lancdLineView = [[UIView alloc] init];
        lancdLineView.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE"];
        [whiteView addSubview:lancdLineView];
        self.landsFirstViewLine = lancdLineView;
        
        /**4:左侧的按钮*/
        UIButton *leftBtn = [[UIButton alloc] initWithButtonText:leftString textColor:[UIColor colorWithHexString:@"#333333"] textFont:16];
        [leftBtn addTarget:self action:@selector(pressLeftBtn) forControlEvents:UIControlEventTouchUpInside];
        [whiteView addSubview:leftBtn];
        self.leftBtn = leftBtn ;
        
        /**5:中间条信息*/
        UIView *vertialLineView = [[UIView alloc] init];
        [whiteView addSubview:vertialLineView];
        vertialLineView.backgroundColor = [UIColor colorWithHexString:@"EEEEEE"];
        self.vertialSecondViewLine = vertialLineView;
        
        /**6：右侧的按钮信息*/
        UIButton *rightBtn = [[UIButton alloc] initWithButtonText:rightString textColor:[UIColor colorWithHexString:@"#333333"] textFont:16];
        [rightBtn addTarget:self action:@selector(pressRightBtn) forControlEvents:UIControlEventTouchUpInside];
        [whiteView addSubview:rightBtn];
        self.rightBtn = rightBtn;
        
        
        [self mackUpSubView];
        
        
    }
    return  self ;
}



/// 2: 布局各种自定义控件


///3: 处理各种对应的按钮或者block的事件
-(void)mackUpSubView {
    
    /**1:布局backView 控件*/
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self).offset(0);
    }];
    
    /**2：白色框View*/
    [self.whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.centerY.equalTo(self.mas_centerY).offset(0);
        make.left.equalTo(self).offset(50);
        make.right.equalTo(self).offset(-50);
        make.height.offset(120);
    }];
    
    /**3:titleLabel展示*/
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.whiteView.mas_top).offset(25);
        make.left.equalTo(self.whiteView.mas_left).offset(0);
        make.right.equalTo(self.whiteView.mas_right).offset(0);
        make.height.offset(16);
    }];
    
    /**4：横向的lineView*/
    [self.landsFirstViewLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.whiteView.mas_left).offset(0);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(24);
        make.right.equalTo(self.whiteView.mas_right).offset(0);
        make.height.offset(0.6);
    }];
    
    /**5:左侧的按钮*/
    [self.leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.whiteView.mas_left).offset(0);
        make.right.equalTo(self.whiteView.mas_centerX).offset(-1);
        make.top.equalTo(self.landsFirstViewLine.mas_bottom).offset(0);
        make.bottom.equalTo(self.whiteView.mas_bottom).offset(0);
    }];
    
    /**6：中间的lineView*/
    [self.vertialSecondViewLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.whiteView.mas_centerX).offset(0);
        make.top.equalTo(self.landsFirstViewLine.mas_bottom).offset(0);
        make.bottom.equalTo(self.whiteView.mas_bottom).offset(0);
        make.width.offset(0.3);
        
    }];
    
    /**7: 右侧的按钮*/
    [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vertialSecondViewLine.mas_right).offset(0);
        make.top.equalTo(self.landsFirstViewLine.mas_bottom).offset(0);
        make.bottom.equalTo(self.whiteView.mas_bottom).offset(0);
           make.right.equalTo(self.whiteView.mas_right).offset(0);
    }];
    
}


/**按钮的点击事件*/
-(void)pressLeftBtn {
      [self removeFromSuperview];
    
}

/// 触犯一个block函数
-(void)pressRightBtn {
    
    self.makeSureBlock();
     [self removeFromSuperview];
}

@end
